<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    computed: {},
    data() {
        return {
            // 外部传入
            appWindow: null,
            loading:false,
            // 数据
            data: [],
            // 配置信息
            config: {
                width: "800px",
                // 表列结构
                // { label: "表头名称", prop: "字段名", type: "显示类型，支持不传、icon" },
                columns: [],
                // 标题
                title: "确定删除以下内容么?",
            },
            // 删除接口地址
            url: "",
            // 窗口显示
            boxVisible: false,
        };
    },
    methods: {
        getText(data_, prop_) {
            let _arr = prop_.split(".");
            let _d = data_;
            for (let i = 0; i < _arr.length; i++) {
                _d = _d[_arr[i]];
            }
            return _d;
        },
        async deleteSubmit() {
            this.loading = true;
            let _ids = this.data.map((item) => {
                return item.id;
            });

            let _d = {
                data: {
                    ids: _ids,
                },
            };
            if (typeof this.url == "object") {
                _d.url = this.url.url;
                _d.domain = this.url.domain;
            } else {
                _d.url = this.url;
            }
            let _data = await this.$vFN.Http.post(_d,
                this.appWindow
            );
            if (_data._ok) {
                this.editBoxClose();
                this.onSuccess();
            }
            this.loading = false;
        },
        // 成功回调
        onSuccess() {},
        // 取消回调
        onCancel() {},
        // 失败回调
        onError() {},
        // 关闭窗口
        editBoxClose() {
            this.boxVisible = false;
        },
        // 取消
        editBoxCancel() {
            this.editBoxClose();
        },

        show(e, item) {
            console.log(e, item);
        },
    },
    watch: {},
    mounted() {
        this.boxVisible = true;
    },
    beforeCreate() {},
};
</script>
